<html>
<head>
	<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
	<script type="text/javascript" src="js/messenger.js"></script>
	<script type="text/javascript" src="main.js"></script>
</head>
<body style="overflow-x:hidden; overflow-y:hidden; margin:0px;">
	<iframe src="http://www.xiami.com/play" width="100%" height="100%" frameborder="0" scrolling="no" id="xiami_player" name="xiami"></iframe>

	<script type="text/javascript">
	var messenger = new Messenger('Main'),
	iframe_xiami = document.getElementById("xiami_player");

	messenger.listen(function (msg) {
		var data = JSON.parse(msg);
		if (data.type == "play_status") {
			if (data.status == "pause-btn") {
				menu.items[0].label = "Pause";
				menu.items[0].icon = "img/pause.svg";
			}else if (data.status == "play-btn") {
				menu.items[0].label = "Play";
				menu.items[0].icon = "img/play.svg";
			}
		} else if (data.type == "play_mode"){
			if (data.mode == "mode-order") {
				submenu.items[0].checked = true;
				submenu.items[1].checked = false;
				submenu.items[2].checked = false;
			} else if (data.mode == "mode-random") {
				submenu.items[0].checked = false;
				submenu.items[1].checked = true;
				submenu.items[2].checked = false;
			} else if (data.mode == "mode-only") {
				submenu.items[0].checked = false;
				submenu.items[1].checked = false;
				submenu.items[2].checked = true;
			}
		}
	});

	messenger.addTarget(iframe_xiami.contentWindow, 'xiami_player');

	function sendMessage(data) {
        messenger.targets['xiami_player'].send(data);
    }
	</script>
</body>
</html>